﻿
@{
    ViewData["Title"] = "Add";
    Layout = "~/Areas/Admin/Views/_Layout.cshtml";
}
<div style="margin-top:3em;margin-right:5em">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">角色名称</label>
            <div class="layui-input-block">
                <input type="text" name="Name" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序码</label>
            <div class="layui-input-block">
                <input type="text" name="SortCode" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">开启过滤</label>
            <div class="layui-input-block">
                <input type="radio" name="isEnabled" value="true" title="开启">
                <input type="radio" name="isEnabled" value="false" title="关闭" checked>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <textarea name="Description" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>

<script>
//Demo
layui.use('form', function(){
  var form = layui.form;
  //监听提交
  form.on('submit(formDemo)', function(data){

      $.post("/admin/role/add", data.field, function (repo)
      {
          layer.msg(repo.msg, { time: 3000 }, function () {
              //当你在iframe页面关闭自身时
              var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
              parent.layer.close(index); //再执行关闭
          });
      });
      return false;
  });
});
</script>

